define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'parentuser/index',
                    add_url: '',
                    edit_url: '',
                    del_url: '',
                    multi_url: 'parentuser/multi',
                    table: 'invite',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),operate:false},
                        {field: 'user.phone', title: __('invitePhone')},
                        {field: 'user.name', title: __('inviteName'),operate:false},
                        {field: 'beinvitePhone', title: __('Phone'),operate:false},
                        {field: 'beinviteName', title: __('Name'),operate:false},
                        {field: 'createTime', title: __('CreateTime'), formatter: Table.api.formatter.datetime,operate: 'BETWEEN', type: 'datetime', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD HH:mm:ss"'},
                        {field: 'firstmoney', title: __('Firstmoney'),operate:false},
                        {field: 'firstcreatetime', title: __('Firstcreatttime'),formatter: Table.api.formatter.datetime,operate:false},
                        {field: 'total', title: __('Total'),operate:false},
                        //{field: 'status', title: __('Status'), formatter: Table.api.formatter.status},

                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            },

        }
    };
    return Controller;
});